import java.util.Random;
import java.util.Scanner;

public class Text4 {
    public static void main(String[] args) {
        //1.生成中奖号码
        int[] arr = createNumber();
        /*for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);*//*
        }*/
        //2.用户输入彩票号码
        int[] userInputArr = userInputNumber();
        /*for (int i = 0; i < userInputArr.length; i++) {
            System.out.print(userInputArr[i] + " ");
        }*/
        //3.判断用户的中奖情况
        int redCount = 0;
        int blueCount = 0;
        //判断红球
        for (int i = 0; i < userInputArr.length-1; i++) {
            int redNumber = userInputArr[i];
            for (int j = 0; j < arr.length-1; j++) {
                if(redNumber==arr[j]){
                    redCount++;
                    //如果找到了，那么后面的数字就没必要继续比较了
                    //跳出内循环，继续判断下一个红球号码
                    break;
                }
            }
        }
        //判断蓝球
        int blueNumber = userInputArr[userInputArr.length-1];
        if(blueNumber==arr[arr.length -1]){
            blueCount++;
        }
        //根据红球和蓝球的个数判断中奖情况
        String prize;
        switch (redCount) {
            case 6:
                switch (blueCount) {
                    case 1:
                        prize = "恭喜您中了一等奖！";
                        break;
                    case 0:
                        prize = "恭喜您中了二等奖！";
                        break;
                    default:
                        prize = "未中奖";
                }
                break;
            case 5:
                switch (blueCount) {
                    case 1:
                        prize = "恭喜您中了三等奖！";
                        break;
                    case 0:
                        prize = "恭喜您中了四等奖！";
                        break;
                    default:
                        prize = "未中奖";
                }
                break;
            case 4:
                switch (blueCount) {
                    case 1:
                        prize = "恭喜您中了四等奖！";
                        break;
                    case 0:
                        prize = "恭喜您中了五等奖！";
                        break;
                    default:
                        prize = "未中奖";
                }
                break;
            case 3:
            case 2:
            case 1:
            case 0:
                switch (blueCount) {
                    case 1:
                        prize = "恭喜您中了六等奖！";
                        break;
                    case 0:
                        prize = "未中奖";
                        break;
                    default:
                        prize = "未中奖";
                }
                break;
            default:
                prize = "未中奖";
        }
        System.out.println(prize);
    }

    public static int[] createNumber() {
        //创建数组存储中奖号码
        //6个红球，1个蓝球，数组长度为7
        int[] arr = new int[7];
        //生成红球号码并添加到数组当中
        Random r = new Random();
        for (int i = 0; i < 6; ) {
            //获取红球号码
            int redNumber = r.nextInt(33) + 1;
            boolean flag = contains(arr, redNumber);
            if (!flag) {
                arr[i] = redNumber;
                i++;
            }
        }
        //生成蓝球号码
        int blueNumber = r.nextInt(16) + 1;
        arr[arr.length - 1] = blueNumber;
        return arr;
    }

    public static int[] userInputNumber() {
        //创建数组用于添加用户购买的彩票号码
        int[] arr = new int[7];
        //键盘录入，用户输入红球号码
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 6; ) {
            System.out.println("请输入第" + (i + 1) + "个红球号码");
            int redNumber = sc.nextInt();
            if (redNumber >= 1 && redNumber <= 33) {
                boolean flag = contains(arr, redNumber);
                if (!flag) {
                    arr[i] = redNumber;
                    i++;
                } else {
                    System.out.println("当前红色号码已存在，请重新输入");
                }
            } else {
                System.out.println("当前红色号码超出范围");
            }
        }
        //输入蓝球号码
        System.out.println("请输入蓝球号码");
        while (true) {
            int blueNumber = sc.nextInt();
            if (blueNumber >= 1 && blueNumber <= 16) {
                arr[arr.length - 1] = blueNumber;
                break;
            } else {
                System.out.println("当前蓝色号码超出范围");
            }
        }
        return arr;
    }

    public static boolean contains(int[] arr, int number) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == number) {
                return true;
            }
        }
        return false;
    }
}

